from sqlalchemy import Column, String, Text, JSON, Integer, DateTime

from app.models.base import BaseModel


class ShipmentMonitor(BaseModel):
    """
    货物追踪表
    """
    __tablename__ = "shipment_monitor"
    
    number_no = Column(String(50), nullable=False, index=True, comment="单号")
    pickup_warehouse = Column(String(100), nullable=False, comment="取货仓库")
    delivery_warehouse = Column(String(100), nullable=False, comment="卸货仓库")
    mac_id = Column(String(50), nullable=False, comment="设备号")
    route_data = Column(JSON, comment="路线数据")
    
    # 新增字段
    pickup_warehouse_coordinates = Column(String(100), comment="取货仓库位置坐标")
    delivery_warehouse_coordinates = Column(String(100), comment="卸货仓库位置坐标")
    start_time = Column(DateTime, comment="开始时间")
    end_time = Column(DateTime, comment="结束时间")
    status = Column(Integer, default=0, comment="状态：0-未开始，10-进行中，30-完成，-10-异常")
    execution_info = Column(Text, comment="执行信息")